package mysql

import "common/models"

func (m Mysql) TypeVideoAdd(val *models.VideoTypeInfo) (err error) {
	return m.Db.Table("video_type_info").Create(&val).Error
}
func (m Mysql) TypeVideoUpdateByID(val *models.VideoTypeInfo) (err error) {
	return m.Db.Table("video_type_info").Where("id = ? ", val.ID).Updates(&val).Error
}
func (m Mysql) TypeVideoQueryByID(Id string) (res *models.VideoTypeInfo, err error) {
	err = m.Db.Table("video_type_info").Where("id = ?", Id).First(&res).Error
	return
}
func (m Mysql) TypeVideoSearchAll(page, size int) (res []*models.VideoTypeInfo, total int64, err error) {
	err = m.Db.Table("video_type_info").Offset((page - 1) * size).Limit(size).Find(&res).Count(&total).Error
	return
}
func (m Mysql) TypeVideoDeleteTrueBy(ID string) (err error) {
	return m.Db.Table("video_type_info").Unscoped().Where("id = ? ", ID).Delete(&models.VideoTypeInfo{}).Error
}
